struct ListNode* detectCycle(struct ListNode* head) {
    struct ListNode* fast = head;
    struct ListNode* slow = head;
    struct ListNode* s = NULL;
    while (fast && fast->next)
    {
        slow = slow->next;
        fast = fast->next->next;
        if (slow == fast)
        {
            s = fast;
            break;
        }
    }
    struct ListNode* t = head;
    while (s)
    {
        if (s = t)
        {
            return s;
        }
        s = s->next;
        t = t->next;
    }
    return NULL;
}